<?
session_start();
$_start_time = explode(" ", microtime());
require_once($_SERVER["DOCUMENT_ROOT"]."/framework/conf/conf_path.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/framework/conf/conf_define.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/framework/conf/conf_database.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/framework/conf/conf_function.php");
require_once(_FRAMEWORK."/core/core_controller.php");

/// @brief Define Core class 
/// @author ggugi
/// @date 2012-07-03
/// @params 
/// @return 

class index extends core_controller
{

    public $result;
	/**
	 * @brief main class 
	 * @date 2012-07-03
	 **/
	public function main()
	{
		$this -> doExecute();  
	}

	/**
	 * @brief 실행 클래스 
	 * @date 2012-07-03
	 **/

	public function doExecute()
	{
		require_once(parent::$sClassPath);
        $sClassName = implode("_", array(parent::$sGroup, parent::$sType, parent::$sMethod));
        $sInstance = new $sClassName;

		switch(parent::$oParam['_format']){
			case "execute"	:
				@header("Content-Type: text/plain; charset=UTF-8");
				$this->result = $sInstance -> main();
                echo parent::output('json', $this->result);
				break;

			case "page"		:
				@header("Content-Type: text/html; charset=UTF-8");
				$this->result = $sInstance -> main();
                $sLayoutPath = _APPLICATION."/".parent::$sActivity."/".parent::$sGroup;
                if(parent::$bUseLayout){
                    $sLayoutPath .= "/resource/layout/".parent::$sMethod;
                }else{
                    $sLayoutPath .= "/resource/template/".parent::$sMethod;
                }
                //if(is_file($sLayoutPath)) helper('error');
                
                @require_once($sLayoutPath);
				break;
		}
	}


}
$_instance = new index();
$_instance -> main();

// Log system logic
$_end_time = explode(" ", microtime());
$_during_time = ($_end_time[0] + $_end_time[1]) - ($_start_time[0] + $_start_time[1]);
debugToFile('debug', $_instance->result,1,'debug',$_during_time);


